
package ija.model.history;

import ija.xls.notation.GameMove;
import ija.xls.notation.NotationReader;
import ija.xls.notation.NotationReaderFactory;
import ija.xls.notation.NotationReaderFactory.NotationType;

/**
 *
 * @author Radek Necas, xnecas18
 */
public class HistoryMove {

    protected int id;
    GameMove move1;
    GameMove move2;
    
    public HistoryMove() {
        id = -1;
        move1 = null;
        move2 = null;
    }
    
    public HistoryMove(int id, NotationType notationType, String firstMove, String secondMove) {
        NotationReader not = NotationReaderFactory.createNotationReader(notationType);
        this.id = id;
        move1 = not.translate(firstMove);
        move2 = not.translate(secondMove);
    }
    
    public HistoryMove(int id, GameMove firstMove, GameMove secondMove) {
        this.id = id;
        move1 = firstMove;
        move2 = secondMove;
    }
    
    public void addFirstMove(GameMove gm) {
        move1 = gm;
    }
    
    public void addSecondMove(GameMove gm) {
        move2 = gm;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public int getId() {
        return id;
    }
    
    public GameMove getFirstMove() {
        return move1;
    }
    
    public GameMove getSecondMove() {
        return move2;
    }
    
    public boolean isComplete() {
        return((id >= 0) && (move1 != null) && (move2 != null));
    }
    
    public void clean() {
        id = -1;
        move1 = null;
        move2 = null;
    }
    
    @Override
    public String toString() {
        return ("id: " + id + " move1: " + move1.toString() + " move2: " + move2.toString());
    }
}
